package com.tzh.plugin.base;

import com.tzh.plugin.utils.PluginAnnotationUtils;
import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;
import org.mybatis.generator.api.dom.java.Interface;
import org.mybatis.generator.api.dom.java.Method;

import java.util.List;


public class MapperGeneratorPlugin extends PluginAdapter {

    @Override
    public boolean validate(List<String> warnings) {
        return true;
    }

    @Override
    public boolean clientBasicCountMethodGenerated(Method method, Interface interfaze,
                                                   IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**查询数量*/");
        return true;
    }

    @Override
    public boolean clientBasicDeleteMethodGenerated(Method method, Interface interfaze,
                                                    IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**删除*/");
        return true;
    }

    @Override
    public boolean clientBasicInsertMethodGenerated(Method method, Interface interfaze,
                                                    IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**插入*/");
        return true;
    }

    @Override
    public boolean clientBasicSelectManyMethodGenerated(Method method, Interface interfaze,
                                                        IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**多条查询*/");
        return true;
    }

    @Override
    public boolean clientBasicSelectOneMethodGenerated(Method method, Interface interfaze,
                                                       IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**单条查询*/");
        return true;
    }

    @Override
    public boolean clientBasicUpdateMethodGenerated(Method method, Interface interfaze,
                                                    IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**更新*/");
        return true;
    }

    @Override
    public boolean clientCountByExampleMethodGenerated(Method method, Interface interfaze,
                                                       IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件查询数量*/");
        return true;
    }


    @Override
    public boolean clientDeleteByExampleMethodGenerated(Method method, Interface interfaze,
                                                        IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件删除*/");
        return true;
    }


    @Override
    public boolean clientDeleteByPrimaryKeyMethodGenerated(Method method, Interface interfaze,
                                                           IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据主键删除*/");
        return true;
    }


    @Override
    public boolean clientInsertMethodGenerated(Method method, Interface interfaze,
                                               IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**插入*/");
        return true;
    }


    @Override
    public boolean clientInsertSelectiveMethodGenerated(Method method, Interface interfaze,
                                                        IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**新增*/");
        return true;
    }

    @Override
    public boolean clientSelectAllMethodGenerated(Method method, Interface interfaze,
                                                  IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**查询*/");
        return true;
    }


    @Override
    public boolean clientSelectByExampleWithBLOBsMethodGenerated(Method method, Interface interfaze,
                                                                 IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件查询*/");
        return true;
    }


    @Override
    public boolean clientSelectByExampleWithoutBLOBsMethodGenerated(Method method, Interface interfaze,
                                                                    IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件查询*/");
        return true;
    }


    @Override
    public boolean clientSelectByPrimaryKeyMethodGenerated(Method method, Interface interfaze,
                                                           IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**查询*/");
        return true;
    }


    @Override
    public boolean clientUpdateByExampleSelectiveMethodGenerated(Method method, Interface interfaze,
                                                                 IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件更新*/");
        return true;
    }


    @Override
    public boolean clientUpdateByExampleWithBLOBsMethodGenerated(Method method, Interface interfaze,
                                                                 IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件更新*/");
        return true;
    }


    @Override
    public boolean clientUpdateByExampleWithoutBLOBsMethodGenerated(Method method, Interface interfaze,
                                                                    IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件更新*/");
        return true;
    }


    @Override
    public boolean clientUpdateByPrimaryKeySelectiveMethodGenerated(Method method, Interface interfaze,
                                                                    IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件更新*/");
        return true;
    }


    @Override
    public boolean clientUpdateByPrimaryKeyWithBLOBsMethodGenerated(Method method, Interface interfaze,
                                                                    IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件更新*/");
        return true;
    }


    @Override
    public boolean clientUpdateByPrimaryKeyWithoutBLOBsMethodGenerated(Method method, Interface interfaze,
                                                                       IntrospectedTable introspectedTable) {
        PluginAnnotationUtils.delDaoClassComment(method);
        method.addAnnotation("/**根据条件更新*/");
        return true;
    }


}
